<template>
	<view class="an-page"> <!-- 本站新闻详情 -->
	
		时间选择器：
		<picker mode="time" :value="time" start="08:00" end="19:00" @change="bindTimeChange">
			<view class="uni-input">{{time}}</view>
		</picker>
	</view>
</template>

<script>
	import anLoading from '@/components/an-loading.vue'
	import { mapActions } from 'vuex'
	export default {
		components:{
			anLoading
		},
		data() {
			return {
				time:"",
				loading: false,
				defaultData: {},
				articleData: {},
				isShare: false,
				pathUrl: '',
				isOK: false, 	// 视频播放地址准备完成
			}
		},
		onLoad(e) {
			try{
				this.defaultData = JSON.parse(decodeURIComponent(e.detailDate));
			}catch(err){
				this.defaultData = JSON.parse(e.detailDate); // 防止URl解码报错
			}
			uni.setNavigationBarTitle({
				title: this.defaultData.title
			})
			if(this.defaultData.isVideo){	// 视频
				this.getVideo()
			}else{
				this.getDetail()
			}
		},
		methods: {
			bindTimeChange: function(e) {
							this.time = e.detail.value
						},
			...mapActions(['getSysInfo']),
			getVideo(){	// 获取播放器地址
				this.loading = true
				this.getSysInfo().then(res=>{ 	// 获取播放地址根目录
					this.loading = false
					this.pathUrl = res.video_path
					this.isOK = true
				})
			},
			getDetail() {	// 获取文章详情
				this.loading = true
				let nd = {
					id: this.defaultData.article_id
				}
				this.$api.articleInfo(nd).then(res=>{
					this.loading = false
					this.articleData = res
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.article-meta {
		padding: 20upx 40upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		color: gray;
	}

	.article-author,
	.article-text,
	.article-time {
		font-size: 15px;
	}
	.article-author{
		margin-right:10px;
	}

	.article-content {
		padding: 0 30upx;
		overflow: hidden;
		font-size: 18px;
		margin-bottom: 30upx;
		text-indent: 2em;	
	}
	
</style>
